Keep Charts preview history in sync - #1179
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 4 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe chart catalog and builder now derive preview history from the current ref, update the ref immediately, and then update React state with the same history snapshot. ChangesPreview history synchronization
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The change synchronously keeps preview history aligned with rapid navigation messages without changing the existing history behavior or API. No actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
tanstack-com | f2ec298 | Commit Preview URL Branch Preview URL |
Aug 26 2026, 03:36 PM |
302e8e3 to
f2ec298
Compare
Evidence
Both Charts preview message handlers read previewHistoryRef.current, but updated that ref inside a React state updater. State updaters can be evaluated after the message handler returns, so a second browser-state message can read stale history and calculate navigation or annotation state from the wrong URL. The Builder instance was also left as an unresolved review finding on merged PR #1171.
The same pattern exists in the catalog result handler. No open issue or PR addresses the synchronization bug. PR #1173 touches the catalog result only to remove an unused callback, not preview history behavior.
Impact
Rapid preview navigation messages now build on the latest accepted history in both Charts surfaces. This prevents stale back and forward entries and annotation targets.
Change
Compute the next history from the current ref, update the ref synchronously, then pass that exact value to React state. This keeps the existing history helper and behavior, with no new abstraction or API change.
The branch is rebased on current main after the Charts Notebook page was renamed to Charts Builder.
Validation
Risk
Low. The same pure updateExamplePreviewHistory result still drives state, but the mutable ref now advances in the message handler before another message can arrive.
Summary by CodeRabbit